package xuexi;

class Yonghu{
    private String yid;
    private String name;
    private Shangping shangping[];

    public Shangping[] getShangping() {
        return shangping;
    }

    public void setShangping(Shangping[] shangping) {
        this.shangping = shangping;
    }

    public String getYid() {
        return yid;
    }

    public void setYid(String yid) {
        this.yid = yid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Yonghu(String yid, String name) {
        this.yid = yid;
        this.name = name;
    }
    public String getInfo(){
        return "【用户信息】 yid="+this.yid+"    name="+this.name;
    }
}
class Shangping{
    private long sid;
    private String name;
    private float price;
    private Yonghu yonghu[];

    public Yonghu[] getYonghu() {
        return yonghu;
    }

    public void setYonghu(Yonghu[] yonghu) {
        this.yonghu = yonghu;
    }

    public Shangping(long sid, String name, float price) {
        this.sid = sid;
        this.name = name;
        this.price = price;
    }

    public long getSid() {
        return sid;
    }

    public void setSid(long sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }
    public String getInfo(){
        return "【商品信息】 yid="+this.sid+"    name="+this.name+"    price="+this.price;
    }
}
public class duoduiduo {
    public  static void main(String[] args){
        Yonghu yonghuA=new Yonghu("111","siwth");
        Yonghu yonghuB=new Yonghu("112","tian");
        Shangping shangpingA=new Shangping(1L,"杜蕾斯",59.9f);
        Shangping shangpingB=new Shangping(2L,"冈本101",59.9f);
        Shangping shangpingC=new Shangping(3L,"杰士邦延时",109.9f);
        yonghuA.setShangping(new Shangping[]{shangpingA,shangpingB,shangpingC});
        yonghuB.setShangping(new Shangping[]{shangpingA,shangpingC});
        shangpingA.setYonghu(new Yonghu[]{yonghuA,yonghuB});
        shangpingB.setYonghu(new Yonghu[]{yonghuA});
        shangpingC.setYonghu(new Yonghu[]{yonghuA,yonghuB});
        System.out.println("----------查看用户浏览的商品----------");
        System.out.println(yonghuA.getInfo());
        for (int x=0;x<yonghuA.getShangping().length;x++) {
            System.out.println("\t|-"+yonghuA.getShangping()[x].getInfo());
        }
        System.out.println(yonghuB.getInfo());
        for (int x=0;x<yonghuB.getShangping().length;x++) {
            System.out.println("\t|-"+yonghuB.getShangping()[x].getInfo());
        }
        System.out.println("----------查看被用户浏览的商品----------");
        System.out.println(shangpingA.getInfo());
        for (int x=0;x<shangpingA.getYonghu().length;x++) {
            System.out.println("\t|-"+shangpingA.getYonghu()[x].getInfo());
        }
        System.out.println(shangpingB.getInfo());
        for (int x=0;x<shangpingB.getYonghu().length;x++) {
            System.out.println("\t|-"+shangpingB.getYonghu()[x].getInfo());
        }
        System.out.println(shangpingC.getInfo());
        for (int x=0;x<shangpingC.getYonghu().length;x++) {
            System.out.println("\t|-"+shangpingC.getYonghu()[x].getInfo());
        }
    }
}
